001 /**
002 * Created by IntelliJ IDEA.
003 * User: Wei Wang
004 * Date: Feb 14, 2003
005 * Time: 9:35:02 PM
006 */
007
008 package EVolve.util.painters.shapes;
009
010 import java.awt.*;
011
012 public class Ball extends Shape{
013 private int diameter;
014
015 public Ball(long entity_type, long entity_id, int diameter) {
016 super(entity_type,entity_id);
017 this.entity_type = entity_type;
018 this.diameter = diameter;
019 }
020
021 public String getName() {
022 return "Box";
023 }
024
025 public void draw(Graphics2D g) {
026 if (color != null) g.setColor(color);
027 g.drawOval(x,y,diameter,diameter);
028
029 if (consumerMap == null) return;
030
031 drawArrows(g);
032 }
033
034 public void fill(Graphics2D g) {
035 if (color != null) g.fillOval(x,y,diameter,diameter);
036 }
037
038 public boolean insideShape(int x, int y) {
039 if ((x<=this.x+diameter) && (x>=this.x) &&
040 (y<=this.y+diameter) && (y>=this.y))
041 return true;
042 return false;
043 }
044
045 public int getWidth() {
046 return diameter;
047 }
048
049 public int getHeight() {
050 return diameter;
051 }
052
053 public void setSize(int width, int height) {
054 diameter = width;
055 }
056 }